/**
 * 与信息相关的接口
 * @author  guocailee
 */
import Vue from 'vue'

/**
 * @description 得到用户信息
 * @required
 * @return {[Object]} [loginInfo]
 */
export const queryUserInfo = () => {
  return new Promise((resolve, reject) => {
    Vue.fetch.post('account/queryuserinfo', {}).then((data) => {
      if (data.body.code === '00000000') {
        resolve(data.body.payload.results)
      } else {
        reject(data.body.message)
      }
    }).catch(data => {
      reject(data)
    })
  })
}
export const updateUserInfo = (info) => {
  return new Promise((resolve, reject) => {
    Vue.fetch.post('account/updateuserinfo', info).then((data) => {
      if (data.body.code === '00000000') {
        resolve()
      } else {
        reject(data.body.message)
      }
    }).catch(data => {
      reject(data)
    })
  })
}
export const chgUserPortrait = (headPortrait) => {
  return new Promise((resolve, reject) => {
    Vue.fetch.post('account/chguserportrait', {
      headPortrait: headPortrait
    }).then((data) => {
      if (data.body.code === '00000000') {
        resolve(data.body)
      } else {
        reject(data.body.message)
      }
    }).catch(data => {
      reject(data)
    })
  })
}

export const setUserAdvancedInfo = (info) => {}
